import Wave from '@/utils/wave'

export default {
  name: 'Button',
  props: {
    wave: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    handleClick (event) {
      event.preventDefault()
      this.$emit('click', event)
    }
  },
  render () {
    const {
      classes,
      disabled,
      handleClick,
      $slots,
      $attrs,
      $listeners,
      wave
    } = this

    const buttonProps = {
      attrs: {
        ...$attrs,
        disabled
      },
      class: classes,
      on: {
        ...$listeners,
        click: handleClick
      }
    }
    let button = <el-button {...buttonProps}>{$slots.default}</el-button>
    return wave ? <Wave>{button}</Wave> : button
  }
}
